package main

import (
	"fmt"
	"strings"
)

func lengthOfLongestSubstring(s string) int {
	str := ""
	maxLen := 0
	for _, c := range s {
		temp := string(c)
		divl := strings.Index(str, temp)
		if divl != -1 {
			if len(str) > maxLen {
				maxLen = len(str)
			}
			str = str[divl+1:]
		}
		str += temp
	}
	if len(str) > maxLen {
		maxLen = len(str)
	}
	return maxLen
}

func main() {
	fmt.Println(lengthOfLongestSubstring("abcabcbb"))
	fmt.Println(lengthOfLongestSubstring("bbbbb"))
	fmt.Println(lengthOfLongestSubstring("pwwkew"))
	fmt.Println(lengthOfLongestSubstring("cdd"))
	fmt.Println(lengthOfLongestSubstring("tmmzuxt"))
}
